﻿<!DOCTYPE html>
<!--岗位安全职责考核审批管理-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }
    </style>
    <style>
        /*说明：
         由于mystyle.css中162行.el-form-item__content {line-height: normal!important;}导致的
         index.css中.el-form-item--mini .el-form-item__content, .el-form-item--mini .el-form-item__label{    line-height: 28px;}失效
         但出于无法修改样式表的情况，所以在该页面添加以下样式，以保证页面内标题和内容不偏离
        */
        .el-form-item--mini .el-form-item__content,
        .el-form-item--mini .el-form-item__label {
            line-height: 28px !important;
        }

        .el-dialog__body {
            height: 200px;
        }
    </style>
    <style>

        .el-input__suffix {
            /* z-index: 9; */
        }

        .cell {
            text-align: center;
        }
    </style>
    <style>
        /*页面内弹窗导致function.js的响应式样式失效，懒得调了，单独写个死样式控制select的样式，勉强能用*/
        .input-with-select .el-input-group__append {
            background-color: #fff;
        }


        .el-input--suffix .el-input__inner {
            
            padding-left: 30px;
        }

        .el-input-group__append {
            width: 150px;
        }
    </style>
</head>

<body>

    <div id="app" v-cloak>
        <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
                 style="margin-bottom: 15px;">
            <el-row>
                <el-col class="head-tool">

                    <div class="new_title fl"><strong><img src="/static/images/icon1.png" />岗位安全职责考核审批列表</strong></div>

                    <span>
                        <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                        </btn>
                        <!--<btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>-->
                        <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                    </span>
                </el-col>
            </el-row>
            <el-row>
                <el-row>
                    <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input v-model="formInline.model.theme"
                                          :placeholder="'填写'+PostSafeResponsibilityExamineManager.assessmentSubject"
                                          size="mini">
                                    <template slot="prepend">
                                        {{PostSafeResponsibilityExamineManager.assessmentSubject+mark.m}}
                                    </template>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{PostSafeResponsibilityExamineManager.year+mark.m}}
                                    </template>
                                    <el-date-picker v-model="formInline.model.assessmentYear" type="year" slot="suffix"
                                                    size="mini" format="yyyy" value-format="yyyy" placeholder="选择年份">
                                    </el-date-picker>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input class="input-with-select" size="mini">
                                    <template slot="prepend">
                                        <div> {{'选择岗位'+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="dutyId" slot="append" placeholder="请选择">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in duties" :label="item.name" :value="item.id"></el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{"审批状态"+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="formInline.model.status" slot="suffix" placeholder="请选择">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option label="未审批" value="1"></el-option>
                                        <el-option label="已审批" value="2"></el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>

                        </div>
                    </el-col>
                    <!--<el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
        <div class="elst-select-mini">
            <el-form-item>
                <el-input size="mini">
                    <template slot="prepend">
                        {{'选择部门'+mark.m}}
                    </template>
                    <treeselect v-model="departmentId" :options="department" :flat="true"
                                slot="suffix" placeholder="请选择"
                                style="line-height: 28px;" />
                </el-input>
            </el-form-item>
        </div>
    </el-col>
    <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
        <div class="elst-select-mini">
            <el-form-item>
                <el-input class="input-with-select" size="mini">
                    <template slot="prepend">
                        <div> {{'选择岗位'+mark.m}}</div>
                    </template>
                    <el-select @visible-change="visibleChange" v-model="dutyId" slot="append" placeholder="请选择">
                        <el-option label="请选择" value=""></el-option>
                        <el-option v-for="item in duties" :label="item.sysDuty.name" :value="item.sysDuty.id"></el-option>
                    </el-select>
                </el-input>
            </el-form-item>
        </div>
    </el-col>-->
                </el-row>
        </el-form>
        <el-table ref="table" stripe :data="ListItem.tableData" :height="ListItem.tableHeight" border
                  @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
            <el-table-column type="selection" align="center" width="55">
            </el-table-column>
            <el-table-column type="index" :label="PostSafeResponsibilityExamineManager.id" :index="indexMethod"
                             width="60" show-overflow-tooltip="true"></el-table-column>
            <el-table-column prop="jG_JobsAssessTask.theme" :label="PostSafeResponsibilityExamineManager.assessmentSubject"
                             show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="jG_JobsAssessTask.assessmentYear" :label="PostSafeResponsibilityExamineManager.assessmentYear" :formatter="myformatDateYear"
                             show-overflow-tooltip="true" width="90">
            </el-table-column>
            <el-table-column prop="mark01" :label="PostSafeResponsibilityExamineManager.post"
                             show-overflow-tooltip="true" width="90">
            </el-table-column>
            <el-table-column prop="mark04" :label="PostSafeResponsibilityExamineManager.assessmentScore"
                             show-overflow-tooltip="true" width="90">
            </el-table-column>
            <el-table-column prop="mark03" :label="PostSafeResponsibilityExamineManager.postPerson" show-overflow-tooltip="true" width="130">
            </el-table-column><!--:formatter="getDicValue"-->
            <el-table-column prop="writeTime" :label="PostSafeResponsibilityExamineManager.writeTime" :formatter="myformatDate"
                             show-overflow-tooltip="true" width="140">
            </el-table-column>
            <el-table-column prop="mark02" :label="PostSafeResponsibilityExamineManager.superiorLeaders"
                             show-overflow-tooltip="true" width="140">
            </el-table-column>
            <el-table-column prop="approvalTime" :label="PostSafeResponsibilityExamineManager.approvalTime" :formatter="myformatDate"
                             show-overflow-tooltip="true" width="140">
            </el-table-column>
            <el-table-column prop="status" :label="PostSafeResponsibilityExamineManager.status"
                             show-overflow-tooltip="true" width="70">
                <template slot-scope="scope">
                    <p v-if="scope.row.status=='0'">
                        未提交
                    </p>
                    <p v-if="scope.row.status=='1'">
                        未审批
                    </p>
                    <p v-if="scope.row.status=='2'">
                        已审批
                    </p>

                </template>
            </el-table-column>
            <el-table-column width="70" prop="update" :label="col.btnApprova" fixed="right">
                <template slot-scope="scope">
                    <!--<button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                <i class="el-icon-edit"></i>
            </button>-->
                    <button v-if="scope.row.status=='1'" type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                        审批
                    </button>
                    <button v-else type="button" class="elst-bt-xg" @click=UserInput2('xg',scope.row.id)>
                        详情
                    </button>
                </template>
            </el-table-column>
        </el-table>
        <el-row type="flex" justify="end">


            <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                           :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                           :layout="ListItem.layout" :total="ListItem.total">
            </el-pagination>

        </el-row>
        <el-dialog title="岗位安全职责考核审批管理" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
                   top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">

        ////获取分页数据
        //function GetPageData1(mythis, currentIndex, url) {
        //    mythis.formInline.offset = (currentIndex - 1) * mythis.ListItem.pagesize;
        //    mythis.formInline.limit = mythis.ListItem.pagesize;
        //    var currObj = mythis;
        //    myAjax("post", mythis, url, mythis.formInline, function (response) {
        //        console.log(response);
        //        if (response.data.pageData.length == 0) {
        //            currObj.ListItem.tableData = [];
        //            currObj.ListItem.total = 0;
        //        } else {
        //            currObj.ListItem.tableData = response.data.pageData[0].jG_JG_JobsAssessDetail
        //            currObj.ListItem.total = response.data.pageData[0].jG_JG_JobsAssessDetail.length;
        //        }
        //    });
        //}
        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    users: [],//UsersTree,
                    ListItem: ListItem,
                    //部门数据集
                    department: [],
                    //职务数据集
                    duties: [],
                    //部门model
                    departmentId: null,
                    //职务model
                    dutyId: null,
                    //选择部门后的信息对象
                    deparmentObject: null,
                    formInline: {
                        model: {
                            name: '', code: '', remark: '', pid: '', theme: '', assessmentYear: '', departmentId: '', dutyId: '', postID: '', postNameID: '', status: '1', mark02: '', mark01: '', mark03: ''
                        },
                        offset: 0,
                        limit: 10
                    },
                    childrenAdd: {},
                    post: [],

                }
            },
            created: function () {
            },
            mounted: function () {

                
                ////初始化部门下拉树数据
                //this.getDepartmentData();
                this.getSysDuty();//岗位初始化
                //this.post = getDicData('postname');
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
            },
            //watch: {
            //    //下拉树监控
            //    departmentId(val, oldval) {
            //        //初始化职务选项
            //        this.dutyId = null;
            //        //获取部门信息（含中间表及职务数据）
            //        this.getDuty(val);
            //        //绑定职务下拉框
            //        this.duties = this.deparmentObject.sysDepartmentDuties;
            //    }
            //},
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //表格序号连续化
                indexMethod: function (index) { return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1; },
                getDicValue: function (row, column, cellValue, index) {
                    switch (column.property) {
                        case "post":
                            return getDicValue('postname', cellValue)
                            break;
                        case "postPerson":
                            var res = '';
                            if (cellValue) {
                                if (typeof cellValue === 'string' || typeof cellValue === 'number') {
                                    res = getTreeValue(this.users, cellValue)
                                }
                                else {
                                    var result = '';
                                    for (var i = 0; i < cellValue.length; i++) {
                                        result += getTreeValue(this.users, cellValue[i]) + ',';
                                    }
                                    result = result.substr(0, result.length - 1);
                                    res = result;
                                }
                            }
                            return res; break;
                        default:
                            return cellValue; break;
                    }
                },

                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/JG_JobsAssess/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "PostSafeResponsibilityExamineApprovalInput.html", id); },
                UserInput2: function (val, id) { DialogShow(this, val, "PostSafeResponsibilityExamineApprovalInputMine.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) {
                    if (this.formInline.model.assessmentYear == null || this.formInline.model.assessmentYear == "" || this.formInline.model.assessmentYear == undefined) { } else {
                        this.formInline.model.assessmentYear = this.formInline.model.assessmentYear.toString().substring(0, 4) + "-01-01 00:00:00.000";
                    }
                    //this.formInline.model.postID = this.departmentId;
                    //this.formInline.model.postNameID = this.dutyId;
                    this.formInline.model.mark02 = this.dutyId;
                    this.formInline.model.mark01 = this.formInline.model.assessmentYear;
                    this.formInline.model.mark03 = this.formInline.model.theme;
                        GetPageData(this, currentIndex, '/api/JG_JobsAssess/GetList')
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                ////初始化部门下拉树(完成)
                //getDepartmentData: function () {
                //    var mythis = this;
                //    myAjax("post", this, '/api/SysDepartment/GetList', { model: { Name: '', Code: '', CreateFactory: null }, offset: 0, limit: 10 }, function (response) {
                //        mythis.department = menuHelper(response.data.pageData, guidEmpty)
                //    }, false);

                //},
                ////联动职务下拉框(完成)
                //getDuty: function (pid) {
                //    var mythis = this;
                //    myAjax("get", mythis, '/api/SysDepartment/Get?id=' + pid, null, function (response) {
                //        console.log(' response.data', response.data)
                //        mythis.deparmentObject = response.data;

                //    }, false);
                //},
                getSysDuty: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/SysDuty/GetList', { model: { Name: '', CreateFactory: null }, offset: 0, limit: 10 }, function (response) {
                        mythis.duties = menuHelper(response.data.pageData, guidEmpty)
                    }, false);
                },

            }
        });
        //下拉树数据格式化
        function menuHelper(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
        //格式化日期
        function myformatDateYear(row, col, cellValue) {

            var time = cellValue;
            if (time) {
                var oldTime = new Date(time.replace(/-/g, "/"));
                return oldTime.getFullYear();
            }
            return "";
        }
    </script>

</body>

</html>